<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学习angularJs</title>
    <script src="./js/angular.min.js"></script>
    <script>
        const app=angular.module('myApp',[])
        app.controller('myController',function ($scope,$location,$http){
            $scope.add=function (){
                const sum=parseInt($scope.number1)+parseInt($scope.number2);
                return sum;
            }
            $scope.showInfo=function () {
                console.log('你被骗了啊')
            }
            $scope.listInfo=[
                {"name":"小王","age":"18","address":"四川南充"},
                {"name":"咖喱","age":"19","address":"四川大仪陇"},
                {"name":"小罗","age":"20","address":"四川遂宁"},
                {"name":"小何","age":"21","address":"巴中野猪"}
            ]
            $scope.location=function () {
                console.log($location)
            }
            $scope.showMessage=function () {
                $http({
                    method: 'GET',
                    url: 'https://api.vvhan.com/api/ian'
                }).then(function successCallback(response) {
                    // 请求成功执行代码
                    console.log(response.data)
                }, function errorCallback(response) {
                    // 请求失败执行代码
                });
            }
        })
    </script>
</head>
<body ng-app="myApp" ng-controller="myController">
请输入你的大名：<input ng-model="name">
<p>名字：{{name}}</p>
<hr/>
<h3>这是一个计算器</h3>
请输入第一个数字：<input ng-model="number1">
请输入第二个数字：<input ng-model="number2">
它的总数为：{{add()}}
<hr/>
点击这个按钮，你会看到惊喜噢<button ng-click="showInfo">惊喜{{showInfo()}}</button>
<hr/>
<ul ng-repeat="user in listInfo">
    <li>{{user.name}}</li>
    <li>{{user.age}}</li>
    <li>{{user.address}}</li>
</ul>
<hr/>
{{location()}}
<hr/>
{{showMessage()}}
</body>
</html>
